//! @Author: DengLibin 榆霖
//! @Date:  2022-04-20 15:25:21
//! @Description: 
//! 

use tokio::runtime::Runtime;
use tokio::time;
use tokio::time::Duration;

async fn fn1(){
    //使用tokio下的sleep
     time::sleep(Duration::from_secs(1)).await; 
     //std::thread::sleep(std::time::Duration::from_secs(2));////标准库中的线程阻塞,阻塞的是系统级线程，对future达不到异步效果。
     println!("fn1 finished!");
    
}


async fn fn2(){
    println!("fn2 finished!")
}

async fn go(){
    //f1等待，则先执行f2
    let f1 = fn1();
    let f2 = fn2();
    //并发执行
    tokio::join!(f1, f2);
    //futures::join!(f1, f2);
}

#[test]
pub fn run(){
    let runtime = Runtime::new().unwrap();
    runtime.block_on(go());
}